package com.bawei.day0129.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.bawei.day0129.Bean.XqBean;
import com.bawei.day0129.base.BaseViewModel;
import com.bawei.day0129.utils.HttpUtils;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * @author 11295 刘铠源
 * 2023/1/30 19:53
 * @类名 XqViewmodel
 */
public class XqViewmodel extends BaseViewModel {
    public XqViewmodel(@NonNull Application application) {
        super(application);
    }
    private MutableLiveData<XqBean> liveData=new MutableLiveData<>();

    public MutableLiveData<XqBean> getLiveData(int infoId) {
        HttpUtils.getHttpUtils().getApisices().findInformation(infoId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<XqBean>() {
                    @Override
                    public void accept(XqBean xqBean) throws Exception {
                        liveData.postValue(xqBean);
                    }
                });
        return liveData;
    }
}
